<%-- ExMobi JSP文件，注释和取消快捷键统一为Ctrl+/ 多行注释为Ctrl+Shift+/ --%>
<%@ page language="java" import="java.util.*"
 contentType="application/text; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/client/adapt.jsp"%>
<%@ include file="/client/adapt_extend.jsp"%>
<%@ include file="properties.jsp" %>
<%!
public synchronized boolean interruptThread(long threadID){
    ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
    Thread[] threads = new Thread[threadGroup.activeCount()];
    threadGroup.enumerate(threads);

    for (Thread thread: threads){
        if ( thread != null && thread.getId() == threadID ){                
            if ( Thread.State.RUNNABLE != thread.getState()){
                try{
                    thread.interrupt();
                    return true;
                } catch (Throwable t){
                    ; // Swallow any exceptions.
                }
            }
        }
    }
    return false;
}
%>
<%
  //根据线程id终止线程
  String tid = aa.req.getParameter("threadid");
  Long threadid = new Long(tid);
  //System.out.println("end thread "+tid+" "+interruptThread(threadid));
  JSONObject outjson = new JSONObject();
  if (interruptThread(threadid)){
	  outjson.put("ret", "ok");
	  outjson.put("msg", "thread "+tid+" end !");
  }else{
	  outjson.put("ret", "fail");
  }
  out.print(outjson.toString());
%>
